<?php
/**
 * Create by PhpStorm
 * User: mozongyou
 * Date: 2021/8/13
 * Time: 4:05 下午
 */

/**
 * 动态索引
 * ${PARAM_DOC}
 * @return ${TYPE_HINT}
 * ${THROWS_DOC}
 * @author mozongyou
 * @date 2021-08-13 4:05 下午
 */
declare(strict_types=1);
namespace App\Repositories\Circle;

use App\Model\Circle\MomentIndex;
use Psr\Container\ContainerInterface;
use Psr\SimpleCache\CacheInterface;

/**
 * 动态索引仓库类
 * Class MomentIndexRpo
 * @package App\Repositories\Circle
 */
class MomentIndexRpo
{
    /**
     * @var ContainerInterface
     */
    protected $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * 获取最新的信息流id
     * @param $id
     * @return array
     * @throws \Psr\SimpleCache\InvalidArgumentException
     * @author mozongyou
     * @date 2021-08-14 11:14 上午
     */
    public function getLastIds($id)
    {
        $momentIds = [];
        $cache = $this->container->get(\Psr\SimpleCache\CacheInterface::class);
        if ($refreshNoticeIds = $cache->get(config('cache-key.app_global_moment_index_ids'))) {
            foreach ($refreshNoticeIds as $value) {
                if ($value > $id) {
                    $momentIds[] = $value;
                }
            }
        }
        return $momentIds;
    }
}